<template>
  <div class="my_dog">
    <img
      src="http://nwzimg.wezhan.cn/contents/sitefiles2029/10146688/images/21129958.jpg"
      alt=""
    />
    <p @click="changecolor" :style="{ background: color }">这是只狗</p>
  </div>
</template>

<script>
export default {
  name: "MyDog2",
  components: {},
  props: {},
  data() {
    return {
      color: "",
    };
  },
  computed: {},
  watch: {},
  created() {},
  methods: {
    changecolor() {
      this.color = `rgb(${Math.floor(Math.random() * 256)},${Math.floor(
        Math.random() * 256
      )},${Math.floor(Math.random() * 256)})`;
    },
  },
};
</script>

<style scoped>
.my_dog {
  width: 200px;
  border: 1px solid black;
  text-align: center;
  float: left;
  margin-right: 10px;
}

.my_dog img {
  width: 100%;
  height: 200px;
}
</style>
